import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapreduce.lib.db.DBWritable;


public class BrRecord implements Writable,DBWritable{
	
	String SUBLOT_ID;
	String GRADE;
	String CHAR_ID;
	String VALUE_TBL;
	String RESV_FIELD4;
	
	 @Override
     public void readFields(DataInput in) throws IOException {
            // TODOAuto-generated method stub
            this.SUBLOT_ID = Text.readString(in);
            this.GRADE = Text.readString(in);
            this.CHAR_ID = Text.readString(in);
             this.VALUE_TBL = Text.readString(in);
            this.RESV_FIELD4 =Text.readString(in);
     }

     @Override
     public void write(DataOutput out) throws IOException {
            // TODO Auto-generatedmethod stub
            Text.writeString(out, this.SUBLOT_ID);
            Text.writeString(out, this.GRADE);
            Text.writeString(out, this.CHAR_ID);
             Text.writeString(out, this.VALUE_TBL);
            Text.writeString(out, this.RESV_FIELD4);
     }

     @Override
     public void readFields(ResultSet result) throws SQLException {
            // TODOAuto-generated method stub
            this.SUBLOT_ID = result.getString("SUBLOT_ID");
            this.GRADE = result.getString("GRADE");
            this.CHAR_ID = result.getString("CHAR_ID");
            this.VALUE_TBL = result.getString("VALUE_TBL");
            this.RESV_FIELD4 = result.getString("RESV_FIELD4");
     }

     @Override
     public void write(PreparedStatement stmt) throws SQLException {
            // TODO Auto-generatedmethod stub
              stmt.setString(1, this.SUBLOT_ID);
              stmt.setString(4, this.GRADE);
              stmt.setString(11, this.CHAR_ID);
              stmt.setString(12, this.VALUE_TBL);
              stmt.setString(14, this.RESV_FIELD4);
     }

     @Override
     public String toString() {
            // TODOAuto-generated method stub
            return new String(this.SUBLOT_ID+ " " + this.GRADE
            		+ " " + this.CHAR_ID+" "+this.VALUE_TBL+" "+this.RESV_FIELD4);
     }
}
